/******************************************************************************
 * Copyright 2024 zhangcong. All Rights Reserved.
 *****************************************************************************/

#include "common/common_log.h"
#include <stdarg.h>

int g_common_log_level = COMMON_LOG_LEVEL_DEBUG;

void Common_Log_Set_Level(int level) {
    if (level >= COMMON_LOG_LEVEL_DEBUG && level <= COMMON_LOG_LEVEL_FATAL) {
        g_common_log_level = level;
    }
}


int Common_Log_Get_Level(void) {
    return g_common_log_level;
}


void Common_Log_writter(const char *file, const char *func, const int line, const int level, const char *fmt, ...) {
    if (level >= g_common_log_level) {
        va_list args;
        va_start(args, fmt);
        printf("[%s][%s][%d] ", file, func, line);
        vprintf(fmt, args);
        printf("\n");
        va_end(args);
    }

    return;
}
